<?php
/**
 * 优惠券控制器前台
 * Created by PhpStorm.
 * User: zxj
 * Date: 17/5/2
 * Time: 下午5:18
 */
namespace App\Http\Controllers\Home;

use App\Models\Favorable;
use App\Models\FavorableUsed;
use App\Models\MyFavorable;


class FavorableController extends BaseController
{

    public function __construct(FavorableUsed $favorableUsed,Favorable $favorable , MyFavorable $myfavorable)
    {
        parent::__construct();
        $this->myfavorable = $myfavorable;
        $this->favorable = $favorable;
        $this->favorableused = $favorableUsed;
    }

    /**
     * @return \Illuminate\Http\JsonResponse
     * 优惠券列表
     */
    public function getListFavorable(){

        $res = $this->favorable->favorable(request());
        return ajax_return($res);

    }

    /**
     * @return \Illuminate\Http\JsonResponse
     * 我的优惠券列表
     */
    public function getListMyFavorable(){
        $res = $this->myfavorable->favorableList(request());
        return ajax_return($res);
    }

    public function getFavorableInfo(){
         $res = $this->favorable->getFavorableInfo(request());
         return ajax_return($res);
    }

    /**
     *  领券
     */
    public function getMyFavorable(){
          $res = $this->favorable->getFavorable(request());
          return ajax_return($res);
    }

    public function getListFavorableUsed(){

        $res = $this->favorableused->favorableList(request());
        return ajax_return($res);

    }

    public function getMyFavorableDetail()
    {
        $res = $this->myfavorable->favorableDetail(request());
        return ajax_return($res);
    }

}